package androidx.viewpager.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import o.fo;

public class PagerTabStrip extends PagerTitleStrip {
    private int ʻ;
    private float ʻॱ;
    private float ʼॱ;
    private int ʽ;
    private int ʾ;
    private int ˊॱ;
    private final Rect ˋॱ;
    private int ˏॱ;
    private int ͺ;
    private final Paint ॱˊ;
    private boolean ॱˋ;
    private boolean ॱˎ;
    private int ॱॱ;
    private int ॱᐝ;
    private int ᐝ;
    private boolean ᐝॱ;

    public PagerTabStrip(@NonNull Context context) {
        this(context, null);
    }

    public PagerTabStrip(@NonNull Context context, @Nullable AttributeSet attributeSet) {
        super(context, attributeSet);
        this.ॱˊ = new Paint();
        this.ˋॱ = new Rect();
        this.ˏॱ = 255;
        this.ॱˋ = false;
        this.ॱˎ = false;
        this.ॱॱ = this.ʼ;
        this.ॱˊ.setColor(this.ॱॱ);
        float f = context.getResources().getDisplayMetrics().density;
        this.ᐝ = (int) ((3.0f * f) + 0.5f);
        this.ʻ = (int) ((6.0f * f) + 0.5f);
        this.ʽ = (int) (64.0f * f);
        this.ͺ = (int) ((16.0f * f) + 0.5f);
        this.ॱᐝ = (int) ((1.0f * f) + 0.5f);
        this.ˊॱ = (int) ((f * 32.0f) + 0.5f);
        this.ʾ = ViewConfiguration.get(context).getScaledTouchSlop();
        setPadding(getPaddingLeft(), getPaddingTop(), getPaddingRight(), getPaddingBottom());
        setTextSpacing(ˊ());
        setWillNotDraw(false);
        this.ˋ.setFocusable(true);
        this.ˋ.setOnClickListener(new OnClickListener(this) {
            final /* synthetic */ PagerTabStrip ˏ;

            {
                this.ˏ = r1;
            }

            public void onClick(View view) {
                this.ˏ.ˊ.setCurrentItem(this.ˏ.ˊ.getCurrentItem() - 1);
            }
        });
        this.ˏ.setFocusable(true);
        this.ˏ.setOnClickListener(new OnClickListener(this) {
            final /* synthetic */ PagerTabStrip ˏ;

            {
                this.ˏ = r1;
            }

            public void onClick(View view) {
                this.ˏ.ˊ.setCurrentItem(this.ˏ.ˊ.getCurrentItem() + 1);
            }
        });
        if (getBackground() == null) {
            this.ॱˋ = true;
        }
    }

    public void setTabIndicatorColor(@ColorInt int i) {
        this.ॱॱ = i;
        this.ॱˊ.setColor(this.ॱॱ);
        invalidate();
    }

    public void setTabIndicatorColorResource(@ColorRes int i) {
        setTabIndicatorColor(fo.ˋ(getContext(), i));
    }

    public void setPadding(int i, int i2, int i3, int i4) {
        if (i4 < this.ʻ) {
            i4 = this.ʻ;
        }
        super.setPadding(i, i2, i3, i4);
    }

    public void setTextSpacing(int i) {
        if (i < this.ʽ) {
            i = this.ʽ;
        }
        super.setTextSpacing(i);
    }

    public void setBackgroundDrawable(Drawable drawable) {
        super.setBackgroundDrawable(drawable);
        if (!this.ॱˎ) {
            this.ॱˋ = drawable == null;
        }
    }

    public void setBackgroundColor(@ColorInt int i) {
        super.setBackgroundColor(i);
        if (!this.ॱˎ) {
            this.ॱˋ = (-16777216 & i) == 0;
        }
    }

    public void setBackgroundResource(@DrawableRes int i) {
        super.setBackgroundResource(i);
        if (!this.ॱˎ) {
            this.ॱˋ = i == 0;
        }
    }

    public void setDrawFullUnderline(boolean z) {
        this.ॱˋ = z;
        this.ॱˎ = true;
        invalidate();
    }

    int ˋ() {
        return Math.max(super.ˋ(), this.ˊॱ);
    }

    public boolean onTouchEvent(MotionEvent motionEvent) {
        int action = motionEvent.getAction();
        if (action != 0 && this.ᐝॱ) {
            return false;
        }
        float x = motionEvent.getX();
        float y = motionEvent.getY();
        switch (action) {
            case 0:
                this.ʻॱ = x;
                this.ʼॱ = y;
                this.ᐝॱ = false;
                break;
            case 1:
                if (x >= ((float) (this.ˎ.getLeft() - this.ͺ))) {
                    if (x > ((float) (this.ˎ.getRight() + this.ͺ))) {
                        this.ˊ.setCurrentItem(this.ˊ.getCurrentItem() + 1);
                        break;
                    }
                }
                this.ˊ.setCurrentItem(this.ˊ.getCurrentItem() - 1);
                break;
                break;
            case 2:
                if (Math.abs(x - this.ʻॱ) > ((float) this.ʾ) || Math.abs(y - this.ʼॱ) > ((float) this.ʾ)) {
                    this.ᐝॱ = true;
                    break;
                }
        }
        return true;
    }

    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        int height = getHeight();
        int left = this.ˎ.getLeft() - this.ͺ;
        int right = this.ˎ.getRight() + this.ͺ;
        int i = height - this.ᐝ;
        this.ॱˊ.setColor((this.ˏॱ << 24) | (this.ॱॱ & 16777215));
        canvas.drawRect((float) left, (float) i, (float) right, (float) height, this.ॱˊ);
        if (this.ॱˋ) {
            this.ॱˊ.setColor(-16777216 | (this.ॱॱ & 16777215));
            canvas.drawRect((float) getPaddingLeft(), (float) (height - this.ॱᐝ), (float) (getWidth() - getPaddingRight()), (float) height, this.ॱˊ);
        }
    }

    void ˏ(int i, float f, boolean z) {
        Rect rect = this.ˋॱ;
        int height = getHeight();
        int i2 = height - this.ᐝ;
        rect.set(this.ˎ.getLeft() - this.ͺ, i2, this.ˎ.getRight() + this.ͺ, height);
        super.ˏ(i, f, z);
        this.ˏॱ = (int) ((Math.abs(f - 0.5f) * 2.0f) * 255.0f);
        rect.union(this.ˎ.getLeft() - this.ͺ, i2, this.ˎ.getRight() + this.ͺ, height);
        invalidate(rect);
    }
}
